Skip to main content
Glama

get contents by user

Fetch user-specific content from TabNews API by specifying username, page, per_page, and strategy to organize posts efficiently.

Instructions

get contents by user from tabnews api

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageNoThe page number to get
per_pageNoThe number of contents per page
strategyNoThe strategy to get the contents
usernameYesThe username to get the contents

Implementation Reference

  • MCP tool handler for 'get contents by user' that invokes the service function and formats the response as MCP text content
    handler: async (params: GetContentByUserParams): Promise<McpResponse> => { try { const result = await getContentsByUser({ username: params.username, page: params.page, per_page: params.per_page, strategy: params.strategy, }); const content: McpTextContent = { type: "text", text: `Contents:\n\n${JSON.stringify(result, null, 2)}`, }; return { content: [content], }; } catch (error) { if (error instanceof Error) { throw new Error(`Failed to get contents by user: ${error.message}`); } else { throw new Error("Failed to get contents by user"); } } },
  • Zod input schema defining parameters for the tool: username (required string), optional page, per_page (numbers), strategy (enum) used for MCP tool validation
    parameters: { username: z.string().describe("The username to get the contents"), page: z.number().optional().describe("The page number to get"), per_page: z.number().optional().describe("The number of contents per page"), strategy: z .enum(["relevant", "new", "old"]) .optional() .describe("The strategy to get the contents"), },
  • src/index.ts:38-43 (registration)
    Registration of the 'get contents by user' tool with the MCP server using server.tool()
    server.tool( getContentsByUserTool.name, getContentsByUserTool.description, getContentsByUserTool.parameters, getContentsByUserTool.handler );
  • Helper service function that performs the actual API fetch to TabNews for contents by user, builds query params and returns the data
    export async function getContentsByUser({ username, page = 1, per_page = 30, strategy = "relevant", }: GetContentByUserParams): Promise<TabNewsContent[]> { const queryParams = new URLSearchParams({ page: page.toString(), per_page: per_page.toString(), strategy: strategy, }); const response = await fetch( `${TABNEWS_API_URL}/contents/${username}?${queryParams}` ); const data = await response.json(); return data as TabNewsContent[]; }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/renant/mcp-tabnews'

If you have feedback or need assistance with the MCP directory API, please join our Discord server